package com.huayanginfo.saas.listener;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.velocity.app.Velocity;

import com.huayanginfo.saas.directory.LDAPService;
import com.huayanginfo.saas.email.EmailClient;

/**
 * server启动时初始化
 * @author rabbit
 *
 */
public class ContextInitListener implements ServletContextListener{

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		Properties properties = new Properties();
		InputStream inputStream = ContextInitListener.class.getResourceAsStream("/velocity.properties");
		try {
			properties.load(inputStream);
		} catch (IOException e) {
			e.printStackTrace();
		}
		Velocity.init(properties);
		try {
			Class.forName(EmailClient.class.getName());
			Class.forName(LDAPService.class.getName());
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		
	}
	

}
